package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;

public class test {
	public static void main(String args[]) throws Exception{

		String wikiStr = "https://ko.wikipedia.org/w/api.php?action=query&format=xml&list=categorymembers&cmlimit=300&cmtitle=";

		String categoryTerm = "분류:라이츄";

		DocumentBuilderFactory factory;
		DocumentBuilder builder;
		Document document;
		
		factory = DocumentBuilderFactory.newInstance();
		builder = factory.newDocumentBuilder();

		document = builder.parse(wikiStr + categoryTerm);
		NodeList nl = document.getElementsByTagName("cm");

		if ( nl.getLength() >= 1 ){
			for(int i = 0; i< nl.getLength(); i++){
				NamedNodeMap attrs = nl.item(i).getAttributes();
				for(int j = 0 ; j<attrs.getLength() ; j++) {
					Attr attribute = (Attr)attrs.item(j);
					if(attribute.getName().equals("title")) System.out.println(attribute.getValue());
				}
			}
		}

	}

}
